<style type="text/css">
img.resize{
    width:200px; /* you can use % */
    height: auto;
}
</style>

<!-- Create a header in the default WordPress 'wrap' container -->
<div class="wrap">
    <div id="icon-plugins" class="icon32"></div>
    <h2>WP cr mobile</h2>

    <h2 class="nav-tab-wrapper">
        <ul id="wp-cr-mobile-tabs">
            <li id="wp-cr-mobile-tab_1" class="nav-tab nav-tab-active">General</li>
            <li id="wp-cr-mobile-tab_2" class="nav-tab">Mobile Form</li>
            <li id="wp-cr-mobile-tab_3" class="nav-tab">Interaction</li>
        </ul>
    </h2>

    <h2><?php echo $title; ?></h2>

    <form method="post" action="<?php echo $formUrl ?>" enctype="multipart/form-data">
        <input type="hidden" name="id" id="id" value="<?php echo $id ?>"/>
        <?php
        wp_nonce_field($mode.'_wp_crmobile _man', $mode.'_wp_crmobile _man_nonce');
        ?>

        <div id="wp-cr-mobile-tabs-content">
            <!-- TAB: General -->
            <div id="wp-cr-mobile-tab-content-1">
                <h3>Information</h3>
                <table class="form-table">
                <?php
                if ($mode == 'edit') { ?>
                <tr valign="top">
                <th scope="row">Review Site<br/></th>
                <td>
                    <?php
                    $reviewUrl = site_url('reviews/'.CRMobile_MobileSite::slugify($company_name).'/');
                    echo "<code><a href='$reviewUrl'>$reviewUrl</a></code>";
                    ?>
                </td>
                </tr>
                <tr valign="top">
                <th scope="row">Shortcodes<br/></th>
                <td>
                    <?php
                    $name = str_replace("'", "", $company_name);
                    echo "<p><code>[crmobile -review id=\"{$id}\"]</code>";
                    echo "<br/><code>[crmobile -review id=\"{$id}\" 
                      exclude=\"name,rating,review,date\" limit=\"10\"]</code></p>";
                    ?>
                    <p class="description">The exclude and limit arguments are optional.</p>
                </td>
                </tr>
                </table>
                <?php } ?>

                <h3>Setup</h3>
                <table class="form-table">
                <tr valign="top">
                <th scope="row"><label for="company_name"><?php _e('Name', 'wp-cr-mobile'); ?></label></th>
                <td>
                    <input type="text" id="company_name" name="company_name" class="regular-text" value="<?php echo $company_name; ?>" />
                    <p class="description"><?php _e('Name of the company.', 'wp-cr-mobile'); ?></p>
                </td>
                </tr>

                <tr valign="top">
                <th scope="row"><label for="company_url"><?php _e('URL', 'wp-cr-mobile'); ?></label></th>
                <td>
                    <input type="text" id="company_url" name="company_url" class="regular-text" value="<?php echo $company_url; ?>" />
                    <p class="description"><?php _e('Company\'s website.', 'wp-cr-mobile'); ?></p>
                </td>
                </tr>

                <tr valign="top">
                <th scope="row"><label for="moderator"><?php _e('Moderator', 'wp-cr-mobile'); ?></label></th>
                <td>
                    <select id="moderator" name="moderator">
                        <option value="0">None</option>
                        <?php
                        foreach ($moderators as $mod) { ?>

                        <option value="<?php echo $mod->ID; ?>"<?php
                        if ($mod->ID == $moderator) {
                            echo ' selected';
                        }
                        ?>><?php echo $mod->display_name; ?></option>
                        <?php } ?>
                    </select>
                    <p class="description">
                    <?php _e('User that can moderate reviews.', 'wp-cr-mobile'); ?> [<a href="<?php echo admin_url('user-new.php'); ?>">Add User</a>] (Select CMob Moderator Role)
                    </p>
                </td>
                </tr>

                <tr valign="top">
                <th scope="row"><label for="star">Stars</label></th>
                <td>
                    <select id="star" name="star">
                        <?php
                        foreach ($stars as $key => $value) { ?>

                        <option value="<?php echo $key; ?>"<?php
                        if ($key == $star) {
                            echo ' selected';
                        }
                        ?>><?php echo $value; ?></option>
                        <?php } ?>
                    </select>
                    <p class="description">
                        Stars to use when presenting the reviews.
                    </p>
                </td>
                </tr>
                </table>
            </div>

            <!-- TAB: Mobile Form -->
            <div id="wp-cr-mobile-tab-content-2">
                <h3><?php _e('Mobile Form', 'wp-cr-mobile'); ?></h3>
                <table class="form-table" style="width: 800px;">
                    <tr valign="top">
                    <th scope="row"><label for="theme"><?php _e('Theme', 'wp-cr-mobile'); ?></label></th>
                    <td>
                        <select id="theme" name="theme">
                            <?php
                            foreach ($themes as $key => $thm) { ?>

                            <option value="<?php echo $key ?>"<?php
                            if ($key === $theme) {
                                echo ' selected';
                            }
                            ?>><?php echo $thm; ?></option>
                            <?php } ?>
                        </select>
                        <p class="description"><?php _e('Theme for the mobile site.', 'wp-cr-mobile'); ?></p>
                    </td>
                    </tr>

                    <tr valign="top">
                    <th scope="row"><label for="exclude"><?php _e('Exclude', 'wp-cr-mobile'); ?></label></th>
                    <td>
                        <input type="checkbox" id="exclude" name="exclude" value="email" <?php
                        if ($email) {
                            echo 'checked ';
                        }
                        ?>/> <?php _e('E-mail', 'wp-cr-mobile'); ?>
                        <p class="description">Check this if you do not want the e-mail field to appear on the mobile form.</p>
                    </td>
                    </tr>

                    <tr valign="top">
                    <th scope="row"><label for="intro"><?php _e('Intro Text', 'wp-cr-mobile'); ?></label></th>
                    <td>
                    <?php
                        wp_editor($intro, 'intro', array('media_buttons' => false, 'textarea_rows' => 5));
                    ?>
                    </td>
                    </tr>

                    <tr valign="top">
                    <th scope="row"><label for="thanks"><?php _e('Thank You Text', 'wp-cr-mobile'); ?></label></th>
                    <td>
                    <select id="thank-you-rating">
                        <option value="5">Thanks Text for Rating 5</option>
                        <option value="4">Thanks Text for Rating 4</option>
                        <option value="3">Thanks Text for Rating 3</option>
                        <option value="2">Thanks Text for Rating 2</option>
                        <option value="1">Thanks Text for Rating 1</option>
                    </select>
                    <?php
                        wp_editor($thanks1, 'thanks1', array('media_buttons' => false, 'textarea_rows' => 5));
                        wp_editor($thanks2, 'thanks2', array('media_buttons' => false, 'textarea_rows' => 5));
                        wp_editor($thanks3, 'thanks3', array('media_buttons' => false, 'textarea_rows' => 5));
                        wp_editor($thanks4, 'thanks4', array('media_buttons' => false, 'textarea_rows' => 5));
                        wp_editor($thanks5, 'thanks5', array('media_buttons' => false, 'textarea_rows' => 5));
                    ?>
                    </td>
                    </tr>

                    <tr valign="top">
                    <th scope="row"><label for="emails"><?php _e('E-mail Text', 'wp-cr-mobile'); ?></label></th>
                    <td>
                    <select id="email-rating">
                        <option value="5">E-mail Text for Rating 5</option>
                        <option value="4">E-mail Text for Rating 4</option>
                        <option value="3">E-mail Text for Rating 3</option>
                        <option value="2">E-mail Text for Rating 2</option>
                        <option value="1">E-mail Text for Rating 1</option>
                    </select>
                    <?php
                        wp_editor($emails1, 'emails1', array('media_buttons' => false, 'textarea_rows' => 5));
                        wp_editor($emails2, 'emails2', array('media_buttons' => false, 'textarea_rows' => 5));
                        wp_editor($emails3, 'emails3', array('media_buttons' => false, 'textarea_rows' => 5));
                        wp_editor($emails4, 'emails4', array('media_buttons' => false, 'textarea_rows' => 5));
                        wp_editor($emails5, 'emails5', array('media_buttons' => false, 'textarea_rows' => 5));
                    ?>
                    </td>
                    </tr>

                    <tr valign="top">
                    <th scope="row"><label for="coupon">Coupon</label></th>
                    <td>
                        <input type="text" id="coupon" name="coupon" class="regular-text" value="<?php echo $coupon; ?>" />
                        <p class="description">Enter an URL to a coupon image.</p>
                    </td>
                    </tr>

                    <tr valign="top">
                    <th scope="row"><label for="emails">Sharing</label></th>
                    <td>
                        <select id="sharing" name="sharing">
                        <?php
                            $sharing_tresholds = array(
                                0 => 'Disabled',
                                1 => '1',
                                2 => '2',
                                3 => '3',
                                4 => '4',
                                5 => '5'
                            );
                            foreach ($sharing_tresholds as $key => $share) { ?>

                            <option value="<?php echo $key ?>"<?php
                            if ($key == $sharing) {
                                echo ' selected';
                            }
                            ?>><?php echo $share; ?></option>
                            <?php } ?>
                        </select>
                        <p class="description">Select a rating threshold to enable sharing reviews to social media.</p>
                    </td>
                    </tr>

                    <tr valign="top">
                    <th scope="row"><label for="logo"><?php _e('Logo', 'wp-cr-mobile'); ?></label></th>
                    <td>
                        <input type="file" name="logo" />
                        <?php
                        if ($logo != '') {
                            echo "<br/><img src='{$logo}' class='resize' />";
                            echo "<br/><input type='checkbox' id='remove_logo' name='remove_logo' value='true' /> Remove Logo";
                        }
                        ?>
                    </td>
                    </tr>
                </table>
            </div>

            <!-- TAB: Interaction -->
            <div id="wp-cr-mobile-tab-content-3">
                <h3>Email Responder</h3>
                <table class="form-table">
                    <tr valign="top">
                    <th scope="row"><label for="service">Service</label></th>
                    <td>
                        <select id="service" name="service">
                            <?php
                            $services = array(
                                ''            => 'None',
                                'aweber'      => 'Aweber',
                                'getresponse' => 'GetResponse',
                                'other'       => 'Other'
                            );
                            foreach ($services as $key => $srv) { ?>

                            <option value="<?php echo $key ?>"<?php
                            if ($key === $service) {
                                echo ' selected';
                            }
                            ?>><?php echo $srv; ?></option>
                            <?php } ?>
                        </select>
                        <p class="description"><?php _e('Select email opt-in service to use.'); ?></p>
                    </td>
                    </tr>

                    <tr valign="top">
                    <th scope="row"><label for="address">Optin Address</label></th>
                    <td>
                        <input type="text" id="address" name="address" class="regular-text" value="<?php echo $address; ?>" />
                        <p class="description">Enter your Aweber or GetResponse campaign name (Single word) or an e-mail address if other.</p>
                    </td>
                    </tr>
                </table>

                <h3>SMS Opt-in</h3>
                <table class="form-table">
                    <tr valign="top">
                    <th scope="row"><label for="sms">SMS</label></th>
                    <td>
                        <input type="checkbox" id="sms" name="sms" value="true" <?php
                        if ($sms) {
                            echo 'checked ';
                        }
                        ?>/> Enable
                        <p class="description">Enable SMS campaigns.</p>
                    </td>
                    </tr>

                    <tr valign="top">
                    <th scope="row"><label for="sms_keyword">Keyword</label></th>
                    <td>
                        <input type="text" id="sms_keyword" name="sms_keyword" class="regular-text" value="<?php echo $sms_keyword; ?>" />
                        <p class="description">Keyword connected to the opt-in list. Example: pizza (71441-US)</p>
                    </td>
                    </tr>
                </table>

                <h3>Social</h3>
                <table class="form-table">
                    <tr valign="top">
                    <th scope="row"><label for="social_facebook">Facebook</label></th>
                    <td>
                        <input type="text" id="social_facebook" name="social_facebook" class="regular-text" value="<?php echo $facebook; ?>" />
                        <p class="description">Facebook page url.</p>
                    </td>
                    </tr>

                <table class="form-table">
                    <tr valign="top">
                    <th scope="row"><label for="social_twitter">Twitter</label></th>
                    <td>
                        <input type="text" id="social_twitter" name="social_twitter" class="regular-text" value="<?php echo $twitter; ?>" />
                        <p class="description">Twitter profile url.</p>
                    </td>
                    </tr>

                <table class="form-table">
                    <tr valign="top">
                    <th scope="row"><label for="social_google">Google+</label></th>
                    <td>
                        <input type="text" id="social_google" name="social_google" class="regular-text" value="<?php echo $google; ?>" />
                        <p class="description">Google+ page url.</p>
                    </td>
                    </tr>
                </table>
            </div>
        </div>

        <p class="submit">
    <?php
        if ($mode == 'new') {
            submit_button(__('Add Company', 'wp-cr-mobile'), 'primary', 'submit', false);
        } else {
            submit_button(__('Save Changes', 'wp-cr-mobile'), 'primary', 'submit', false);
        }
    ?>
        <a href="<?php echo $formUrl ?>" class="button"><?php _e('Cancel', 'qp-cr-mobile'); ?></a>
        </p>
    </form>
</div><!-- /.wrap -->
